#include "net/poll_thread.h"
#include "net/poller.h"

namespace net {
PollThread::~PollThread() {
  if (poller_.get()) {
    poller_.reset();
  }
}

Poller* PollThread::Poll() {
  if (!poller_.get()) {
    poller_.reset(CreatePoller());
    if (!poller_->Init()) {
      poller_.reset();
      return NULL;
    }
    poller_->LoopInAnothreadThread();
  }

  return poller_.get();
}
}
